<div class='wrap-course-list right-cont' ng-controller='CourseList'>
    <div class='title'>课程列表<i class='fa fa-spinner fa-spin' ng-if='loading'></i></div>
    <div class='content'>
        <div class='box-ops'>
            <button class='btn btn-primary' data-toggle='modal' data-target='.add-course'>添加</button>
            <div class='box-search-date'>
                <div class='input-group'>
                    <span class='input-group-addon'>始</span>
                    <input type='text' class='form-control input-date' ng-model='dateS'>
                    <span class='input-group-addon'>末</span>
                    <input type='text' class='form-control input-date' ng-model='dateE'>
                    <span class='input-group-btn'>
                        <button class='btn btn-primary' type='button' ng-click='load_data()'>搜索</button>
                    </span>
                </div>
            </div>
        </div>
        <div class='box-list'>
            <table class='table table-list'>
                <tr>
                    <td>课程ID <span class='fa fa-sort'></span></td>
                    <td>名称<span class='fa fa-sort'></span></td>
                    <td>讲师<span class='fa fa-sort'></span></td>
                    <td>章节数<span class='fa fa-sort'></span></td>
                    <td>价格<span class='fa fa-sort'></span></td>
                    <td>积分<span class='fa fa-sort'></span></td>
                    <td>类型<span class='fa fa-sort'></span></td>
                    <td>售出数量<span class='fa fa-sort'></span></td>
                    <td>添加时间<span class='fa fa-sort'></span></td>
                    <td>购买类型<span class='fa fa-sort'></span></td>
                    <td>状态<span class='fa fa-sort'></span></td>
                    <td>操作<span class='fa fa-sort'></span></td>
                </tr>
                <tr ng-repeat='item in list'>
                    <td>{{item.id || '未知'}}</td>
                    <td>{{item.sim_name || '未知'}}</td>
                    <td>{{item.teacher_name || '未知'}}</td>
                    <td>{{item.chapter || 0}}</td>
                    <td>{{item.price || '未知'}}</td>
                    <td>{{item.score || '未知'}}</td>
                    <td>{{item.cate_text || '未知'}}</td>
                    <td>{{item.buy_count || 0}}</td>
                    <td>{{item.create_date || '未知'}}</td>
                    <td>{{item.buy_type_text || '未知'}}</td>
                    <td>
                        <span class='label label-success' ng-if='item.status == 1'>
                            {{item.status_text || '未知'}}
                        </span>
                        <span class='label label-warning' ng-if='item.status == 0'>
                            {{item.status_text || '未知'}}
                        </span>
                    </td>
                    <td>
                        <button class='btn btn-primary btn-xs btn-w-xs' ng-click='get_item(item)'>编辑</button>
                        <button class='btn btn-warning btn-xs btn-w-xs' 
                            ng-click='update_item(item.id, {"status" : 0})'
                            ng-if='item.status == 1'>
                            下架
                        </button>
                        <button class='btn btn-success btn-xs btn-w-xs' 
                            ng-click='update_item(item.id, {"status" : 1})'
                            ng-if='item.status == 0'>
                            上架
                        </button>
                        <button class='btn btn-primary btn-xs btn-w-xs' ng-click='into_chapter(item.id)'>
                            章节
                        </button>
                    </td>
                </tr>
            </table>
            <div class='box-page' ng-bind-html='pageHtml'></div>
        </div>
    </div>

    <!-- 课程添加模态窗 -->
    <div class='modal fade add-course'>
        <div class='modal-dialog'>
            <div class='modal-content' align='center'>
                <div class='modal-header'>
                    课程添加
                    <a class='close' data-dismiss='modal'>&times;</a>
                </div>
                <div class='modal-body'>
                    <table class='table-form'>
                        <tr>
                            <td class='td-label'>课程名称:</td>
                            <td colspan='3'>
                                <input type='text' class='form-control' ng-model='aItem.name'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>主标题:</td>
                            <td colspan='3'>
                                <input type='text' class='form-control' ng-model='aItem.main_title'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>副标题:</td>
                            <td colspan='3'>
                                <input type='text' class='form-control' ng-model='aItem.sub_title'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>课程类型:</td>
                            <td>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='aItem.cate' value='1'>必修
                                </div>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='aItem.cate' value='2'>选修
                                </div>
                            </td>
                            <td class='td-label'>主讲教师:</td>
                            <td>
                                <select class='form-control' ng-model='aItem.teacher_id'>
                                    <option ng-repeat='t in teachers' value='{{t.id}}'>{{t.name}}</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>购买方式:</td>
                            <td>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='aItem.buy_type' value='1'>现金
                                </div>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='aItem.buy_type' value='2'>积分
                                </div>
                            </td>
                            <td class='td-label' ng-if='aItem.buy_type == 1'>购买价格:</td>
                            <td ng-if='aItem.buy_type == 1'>
                                <input type='text' class='form-control' ng-model='aItem.price'>
                            </td>
                            <td class='td-label' ng-if='aItem.buy_type == 2'>购买积分:</td>
                            <td ng-if='aItem.buy_type == 2'>
                                <input type='text' class='form-control' ng-model='aItem.score'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>课程描述:</td>
                            <td colspan='3'>
                                <textarea ng-model='aItem.decipt' class='form-control'></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>课程图片:</td>
                            <td colspan='2' class='box-banner'><img ng-src='{{aItem.banner}}'></td>
                            <td style='position: relative;'>
                                <button class='btn btn-success btn-upload-show'>上传</button>
                                <button class='btn-upload' id='upload-add'>上传</button>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class='modal-footer'>
                    <button class='btn btn-primary btn-sm btn-w-sm' ng-click='add_item(aItem)'>确认</button>
                    <button class='btn btn-default btn-sm btn-w-sm' data-dismiss='modal'>取消</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 课程编辑模态窗 -->
    <div class='modal fade edit-course'>
        <div class='modal-dialog'>
            <div class='modal-content' align='center'>
                <div class='modal-header'>
                    课程编辑
                    <a class='close' data-dismiss='modal'>&times;</a>
                </div>
                <div class='modal-body'>
                    <table class='table-form'>
                        <tr>
                            <td class='td-label'>课程名称:</td>
                            <td colspan='3'>
                                <input type='text' class='form-control' ng-model='nItem.name'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>主标题:</td>
                            <td colspan='3'>
                                <input type='text' class='form-control' ng-model='nItem.main_title'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>副标题:</td>
                            <td colspan='3'>
                                <input type='text' class='form-control' ng-model='nItem.sub_title'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>课程类型:</td>
                            <td>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='nItem.cate' value='1'>必修
                                </div>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='nItem.cate' value='2'>选修
                                </div>
                            </td>
                            <td class='td-label'>主讲教师:</td>
                            <td>
                                <select class='form-control' ng-model='nItem.teacher_id'>
                                    <option ng-repeat='t in teachers' value='{{t.id}}'>{{t.name}}</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>购买方式:</td>
                            <td>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='nItem.buy_type' value='1'>现金
                                </div>
                                <div class='box-radio'>
                                    <input type='radio' ng-model='nItem.buy_type' value='2'>积分
                                </div>
                            </td>
                            <td class='td-label' ng-if='nItem.buy_type == 1'>购买价格:</td>
                            <td ng-if='nItem.buy_type == 1'>
                                <input type='text' class='form-control' ng-model='nItem.price'>
                            </td>
                            <td class='td-label' ng-if='nItem.buy_type == 2'>购买积分:</td>
                            <td ng-if='nItem.buy_type == 2'>
                                <input type='text' class='form-control' ng-model='nItem.score'>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>课程描述:</td>
                            <td colspan='3'>
                                <textarea ng-model='nItem.decipt' class='form-control'></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class='td-label'>课程图片:</td>
                            <td colspan='2' class='box-banner'><img ng-src='{{nItem.banner}}'></td>
                            <td style='position: relative;'>
                                <button class='btn btn-success btn-upload-show'>上传</button>
                                <button class='btn-upload' id='upload-edit'>上传</button>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class='modal-footer'>
                    <button class='btn btn-primary btn-sm btn-w-sm' ng-click='update_item(nItem.id, nItem)'>确认</button>
                    <button class='btn btn-default btn-sm btn-w-sm' data-dismiss='modal'>取消</button>
                </div>
            </div>
        </div>
    </div>
</div>